﻿namespace LedCenter.Models
{
    interface IBaseDevice
    {
        string ToXML();
    }

    public abstract class BaseDevice : IBaseDevice, IConnectable
    {
        public const string LOG_FOLDER = "./Logs/";
        // Device name
        public string Name { get; set; }
        // IMEI number
        public string IMEI { get; set; }
        // Device type
        public DEVICE_TYPE Type { get; set; }
        // Device image
        public string Password { get; set; }
        // Device position
        public float Longtitude;
        public float Latitude;

        // Device log path
        // auto generated: logpath = ${Log folder}/${Name}.log
        public string LogPath { get { return LOG_FOLDER + Name + ".log"; } }

        /* 
         * Constructors 
        **/
        /// <summary>
        /// Default Constructor
        /// </summary>
        /// <returns></returns>
        public BaseDevice()
        {
            Name = "Base devices";
            Type = DEVICE_TYPE.UNKNOW;
            Password = "";
        }

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="name">Device's name</param>
        /// <param name="type">Device's type</param>
        /// <param name="password">Password to access device</param>
        public BaseDevice(string name,string imei,DEVICE_TYPE type,string password)
        {
            Name = name;
            IMEI = imei;
            Type = type;
            Password = password;
        }

        public virtual string ToXML()
        {
            return "xml";
        }

        public virtual string open()
        {
            //throw new System.NotImplementedException();
            return "Not implemented";
        }

        public virtual void close()
        {
            //throw new System.NotImplementedException();
        }

        public virtual string writeData(byte[] data, int length)
        {
            //throw new System.NotImplementedException();
            return "Not implemented";
        }
    }

    public enum DEVICE_TYPE
    {
        SMS,
        TCP,
        UNKNOW
    }
}
